/*
 * opencog/atomspace/Transient.h
 *
 * Copyright (C) 2008,2009,2014,2015 Linas Vepstas
 *
 * Author: Linas Vepstas <linasvepstas@gmail.com>  February 2008
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License v3 as
 * published by the Free Software Foundation and including the exceptions
 * at http://opencog.org/wiki/Licenses
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program; if not, write to:
 * Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef _OPENCOG_TRANSIENT_H
#define _OPENCOG_TRANSIENT_H

namespace opencog
{

class AtomSpace;
AtomSpace* grab_transient_atomspace(AtomSpace*);
void release_transient_atomspace(AtomSpace*);

// Handy wrapper to provide RAII when exceptions gt thrown.
struct Transient
{
	AtomSpace* tmp;
	Transient(AtomSpace* as) : tmp(grab_transient_atomspace(as)) {}
	~Transient() { release_transient_atomspace(tmp); }
};

} //namespace opencog

#endif // _OPENCOG_TRANSIENT_H
